import { seacrhWarehousing } from "@/views/wy-asset-management/warehousing/api/warehousing.js";
import assetDictionary from "@/views/wy-asset-management/mixin/assetDictionary";
import { mapGetters } from "vuex";
import { getDict } from "~/utils";
export default {
	mixins: [assetDictionary],
	data() {
		return {
			//入库附件
			wfileList: [],
			activeName: "资产变更信息",
			countys: [],
			citys: [],
			provinces: [],
			loading: true,
			modelType: "asset-warehousing",
			//弹出框 初始时隐藏
			dialogVisible: false,
			government: 0,
			formObj: {
				warehousingAttachment: "",
				//基本信息
				roomId: "",
				cardType: "",
				assetFixedWarehousingId: this.$route.query.assetFixedWarehousingId,
				assetName: "",
				assetClassification: "",
				useStatus: "",
				acquisitionMethod: "",
				acquisitionDate: "",
				investmentAcquisitionDate: "",
				valueType: 0,
				registrationPrice: 0,
				registrationFee: 0,
				taxation: 0,
				value: 0,
				number: "",
				measurementUnit: 0,
				landArea: 0,
				propertyRightForm: 0,
				ownershipCertificateNo: "",
				issueData: "",
				ownershipPeriod: "",
				ownershipCertificate: 0,
				location: "",
				ownershipNature: 0,
				selfUseArea: 0,
				selfUseValue: 0,
				buildingStructure: 0,
				assetCode: "",
				voucherNo: "",
				voucherDateStart: "",
				voucherDateEnd: "",
				warehousingStatus: 1, //入库状态
				assetFixedWarehousingLogList: []
				//文件
			},
			fileList: [],
			formObj2: {
				assetCode2: "",
				voucherNo2: "",
				voucherDate: [],
				warehousingStatus: 1 //入库状态
			}
		};
	},
	/**
	 * 载入事件
	 */
	mounted() {
		//根据主键查询已入库的信息
		this.getWarehousing();
	},
	computed: {
		...mapGetters({
			cityAssembly: "getCityAssembly",
			districtCollection: "getDistrictCollection"
		})
	},
	methods: {
		// 是否有不动产证改变事件
		handleARealEstateCertificate() {
			this.formObj.cardType = "";
		},
		getDict(v) {
			return getDict(v);
		},
		/**
		 * 根据主键查询已入库的信息
		 */
		getWarehousing() {
			this.loading = true;
			seacrhWarehousing(this.$route.query.assetFixedWarehousingId)
				.then(resp => {
					this.formObj = resp.data.data;
					this.government = this.formObj.assetRegistrationId == "1" ? "1" : "0";
					this.formObj2.assetCode2 = resp.data.data.assetCode;
					this.formObj2.voucherNo2 = resp.data.data.voucherNo;
					this.$set(
						this.formObj2.voucherDate,
						"0",
						resp.data.data.voucherDateStart
					);
					this.$set(
						this.formObj2.voucherDate,
						"1",
						resp.data.data.voucherDateEnd
					);
					this.loading = false;
				})
				.catch(error => {
					this.$message({
						type: "error",
						message: "获取物业入库信息失败"
					});
				})
				.finally(() => (this.loading = false));
		},
		//返回
		goBack() {
			this.$router.push("/asset-management/warehousing-list");
		}
	}
};
